    <%--
  Created by IntelliJ IDEA.
  User: FENG1
  Date: 2022/5/19
  Time: 15:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";%>
<html>
<head>
    <base href="<%=basePath%>">
    <title>Title</title>
    <link rel="stylesheet" href="static/component/pear/css/pear.css" />
    <link rel="stylesheet" href="static/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="static/css/public.css" media="all">
    <style>
        .layui-table-cell{
            height:auto;
            line-height: 80px;
        }
        .layui-table th span{
            font-weight: bold;
            color: #0C0C0C;
        }
    </style>
</head>
<body>
<div class="layuimini-container">
    <button class="layui-icon layui-btn layui-btn-normal" id="window-comeback">&#xe65c;</button>
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" >
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">商品名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="goodsName" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">商品供货商</label>
                            <div class="layui-input-inline">
                                <select name="supplierid" class="layui-input">
                                    <option value="">全部供货商</option>
                                    <c:forEach items="${supp}" var="s">
                                        <option value="${s.supplierId}">${s.supplierName}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="invFormSubmit"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <script type="text/html" id="inv-toolbar">
            <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
                <i class="layui-icon layui-icon-add-1"></i>
                新增
            </button>
            <button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
                <i class="layui-icon layui-icon-delete"></i>
                删除
            </button>
        </script>
        <table class="layui-hide" id="currentTableId" lay-filter="invTableFilter"></table>
    </div>
</div>
<script src="static/component/layui/layui.js"></script>
<script src="static/component/pear/pear.js"></script>
<script>
    var windowComeback = document.getElementById('window-comeback');
    windowComeback.addEventListener('click', function () {
       window.history.back(-1);
    });
</script>
<script type="text/html" id="imgtmp">
    <img src="{{d.goodsImg}}" style="width:80px;height:80px">
</script>
<script>
    //引入table
    layui.use(['table','form'],function () {
        var $ = layui.jquery;
        var from = layui.form;
        var table = layui.table;
        var form = layui.form;
        //执行表格的数据填充操作
        table.render({
            //指定渲染的表格
            elem: '#currentTableId',
            //指定获取数据的路径
            url: 'stock/allStock?reponseTypePid='+${inv.reponseTypePid},
            toolbar: '#inv-toolbar',
            //规定请求方式
            method: 'post',
            //开启分页
            page: true,
            check: true,
            //指定每页显示数
            limits: [1, 10, 15,20],//每页条数的选择项
            even: true,
            cols: [[
                {type: 'checkbox'},
                {field:'goodsImg',title:'商品图片', align: 'center',templet: "#imgtmp"},
                {field: 'goodsName', title: '商品名称', align: 'center'},
                {field: 'goodsPrice', title: '商品价格', align: 'center'},
                {field: 'capacity', title: '商品容量', align: 'center'},
                {field: 'specifiCations', title: '商品单位', align: 'center'},
                {field: 'supplierName', title: '商品供应商', align: 'center'},
                {field: 'stockCount', title: '商品库存', align: 'center'},
                {field: 'reponseTypeName', title: '所属仓库',align: 'center'},
            ]],
        })
        //from表单提交事件
        form.on('submit(invFormSubmit)',function (data){
            //执行搜索重载
            table.reload('currentTableId',{
                //规定默认第几页
                page:{
                    curr:1
                },
                where:{
                    //添加请求参数
                    goodsName:data.field.goodsName,
                    supplierId:data.field.supplierId,
                }
            });
            return false;
        })
    })
</script>
</body>
</html>